package LeetCode;

public class LC_503_NextGreaterElementII {

    public static void main(String[] args) {

    }

    public class Solution {
        public int[] nextGreaterElements(int[] nums) {
            int[] res = new int[nums.length];
            for (int i = 0; i < nums.length; i++) {
                boolean find = false;
                int j = i + 1;
                for (int ignored : nums) {
                    if (j >= nums.length) j = 0;
                    if (nums[j] > nums[i]) {
                        find = true;
                        res[i] = nums[j];
                        break;
                    }
                    j++;
                }
                if (!find) res[i] = -1;
            }
            return res;
        }

    }
}